package com.itcast.demo.demo1.Enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum TestEnums {


    MALE("男",18,"北京"),
    FEMALE("女",19,"上海"),
    UNKNOWN("未知",20,"火星");

    private final String name;
    private final int age;
    private final String address;

    TestEnums(String name,int age,String address){
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public static TestEnums getTestEnum(String name){

        TestEnums testEnums = Arrays.stream(TestEnums.values())
                .filter(e -> name.equals(e.getName()))
                .findFirst()
                .orElse(UNKNOWN);
        return testEnums;
    }

}
